package com.yzd.learnjava.io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import com.yzd.learnjava.util.Print;

public class StoringAndReconeringData {
	public static void main(String[] args) throws IOException {
		DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream("Data.txt")));
		out.writeDouble(3.14159);
		out.writeUTF("That was Pi");
		out.writeDouble(1.41413);
		out.writeUTF("Square root of 2");
		out.close();
		
		DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream("Data.txt")));
		Print.print(in.readDouble());
		Print.print(in.readUTF());
		Print.print(in.readDouble());
		Print.print(in.readUTF());
	}
}
